

<%@page import="com.etc.entity.Users"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib prefix="c"  uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge, maximum-scale=1">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <meta name="description" content="">
    <meta name="author" content="">
    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
    <script src="dist/js/bootstrap.js"></script>
    <link rel="icon" href="../../favicon.ico">

    <title>猪大头超市</title>
 
    <!-- Bootstrap core CSS -->
    <link href="dist/css/bootstrap.css" rel="stylesheet">



    <!-- Custom styles for this template -->
    <link href="dist/css/dashboard.css" rel="stylesheet">

    <!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
    <!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->


    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>

  <body>
<%-- <%@ include file ="session.jsp" %> --%>
  
  

    <nav class="navbar navbar-inverse navbar-fixed-top">
      <div class="container-fluid">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="#">悦舍住户操作界面</a>
        </div>
        <div id="navbar" class="navbar-collapse collapse">
          <ul class="nav navbar-nav navbar-right">
            <li><a href="#">商品展示</a></li>
            <li><a href="#">设置</a></li>
            <li><a href="#">帮助</a></li>
            <li ><a href="dengru1.jsp" class="btn btn-danger">退出登入</a></li>
          </ul>
          <form class="navbar-form navbar-right"  action="Testservlet?op=mohu" method="post">
            <input type="text" class="form-control" placeholder="搜索..." name = "name1">
            <button type="submit" class="btn btn-primary">搜索</button>
          </form>
        </div>
      </div>
      
    </nav>


    <div class="container-fluid">
      <div class="row">
        <div class="col-sm-3 col-md-2 sidebar">
          <ul class="nav nav-sidebar">
            <li class="active"><a href="us.do">用户管理 <span class="sr-only">(current)</span></a></li>
            <li><a href="" >增加用户</a></li>
            <li ><a href="">提交问题</a></li>
            <li ><a href="">显示问题</a></li>
            <li ><a href="us.do?op=queryBypage">分页显示[JSTL]</a></li>
          </ul>
          <ul class="nav nav-sidebar">
            <li><a href="">Nav item</a></li>
 
          </ul>
          <ul class="nav nav-sidebar">
            <li><a href="">Nav item again</a></li>
      
          </ul>
        </div>
        <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">

          
 	<div class="table-responsive" >
          <h2 class="sub-header">用户信息管理</h2>
            <table class="table table-striped">
              <thead>
                <tr>
                  <th>编号</th>
                  <th>用户名</th>
                  <th>登入密码</th>
                  <th>性别</th>
                  <th>电话</th>
                  <th>公寓名字</th>
                  <th>房间号</th>
                  <th>入住日期</th>
                  <th>是否启用状态</th>
                  <th>操作</th>
                </tr>
              </thead>
              <tbody>
        
              <% 
              if(request.getAttribute("list")!=null){
           		Object obj = request.getAttribute("list");
           		if (obj instanceof Users){
           			Users p = (Users) obj;
         
		%>
                <tr>
                  <td><%= p.getUserId() %></td>
                  <td><%= p.getUserName() %></td>
                  <td><%= p.getUserPwd() %></td>
                  <td><%= p.getUserSex() %></td>
                  <td><%= p.getUserTel() %></td>
                  <td><%= p.getHouseName() %></td>
                  <td><%= p.getUserDoorNO() %></td>
                  <td><%= p.getUserDate() %></td>
                  <td><%= p.getUserState()==0?"未激活":"已激活" %></td>
                   <td>
   				    <!-- 使用超链接来修改用户 -->
   				   <a id="modal-790227" href="#modal-container-790227" role="button" class="btn btn-danger update" data-toggle="modal">修改</a>
                   <!-- 使用超链接来删除用户 -->
                   <a href="Testservlet?op=del&userId=<%=p.getUserId() %>" class="btn btn-danger">删除</a></td>
                </tr>
                <%	} 
           		
          	} %>
              </tbody>
            </table>
          </div>
        </div>
      </div>
    </div>

<!-- 模态窗体 -->
<div class="row clearfix">
		<div class="col-md-12 column">
			 
			
			<div class="modal fade" id="modal-container-790227" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
				<div class="modal-dialog">
					<div class="modal-content">
						<div class="modal-header">
							 <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
							<h4 class="modal-title" id="myModalLabel">
								修改功能
							</h4>
						</div>
						<div class="modal-body">
							<form class="form-horizontal" action="Testservlet?op=update" method="post">
							<div class="form-group">
						<label for="userId" class="col-sm-2 control-label">用户ID</label>
						<div class="col-sm-4">
							<input type="text" class="form-control" id="userId"
								 name="userId" readonly="readonly" >
						</div>
					</div>
					<div class="form-group">
						<label for="username" class="col-sm-2 control-label">用户名</label>
						<div class="col-sm-4">
							<input type="text" class="form-control" id="userName"
								placeholder="请输入用户名" required="required" name="userName">
						</div>
					</div>
					
					<div class="form-group">
						<label for="inputPassword3" class="col-sm-2 control-label">性别</label>
						<div class="col-sm-4">
							<select class="form-control" name="userSex" id="userSex">
							   <option value="男">男</option>
							   <option value="女">女</option>
							</select>
						</div>
					</div>
					
					<div class="form-group">
						<label for="inputPassword3" class="col-sm-2 control-label">电话号码</label>
						<div class="col-sm-4">
							<input type="text" class="form-control" id="userTel"
								placeholder="请输入电话号码"  required="required" name="userTel">
						</div>
					</div>
					
					<div class="form-group">
						<label for="inputPassword3" class="col-sm-2 control-label">用户地址</label>
						<div class="col-sm-6">
							<input type="text" class="form-control" id="userAddress"
								placeholder="请输入地址"   name="userAddress">
						</div>
					</div>
							
					<div class="form-group">
						<label for="inputPassword3" class="col-sm-2 control-label">用户等级</label>
						<div class="col-sm-4">
							<select class="form-control" name="userState" id="userState">
							   <option value="1">启用</option>
							   <option value="0">禁用</option>
							</select>
						</div>
					</div>
					
					<div class="form-group">
						<div class="col-sm-offset-2 col-sm-10">
	</div>
						<div class="modal-footer">
							 <button type="button" class="btn btn-default" data-dismiss="modal">关闭
							 </button> <button type="submit" class="btn btn-primary">保存</button>
						</div> 
						</div>
					</div>
				</form>
					
					</div>
					
				</div>
				
			</div>
			
		</div>
	</div>
	<script>
	
	$(function(){
		$(".update").click(function(){
			var userId=$(this).parents("tr").find("td").eq(0).text();
			var userName=$(this).parents("tr").find("td").eq(1).text();
			var userSex=$(this).parents("tr").find("td").eq(3).text();
			var userTel=$(this).parents("tr").find("td").eq(4).text();
			var userState=$(this).parents("tr").find("td").eq(7).text();
			console.log(userId);
			
			$("#userId").val(userId);
			$("#userName").val(userName);
			$("#userSex").val(userSex);
			$("#userTel").val(userTel);
			$("#userState").val(userState=="启用"?1:0);
		});
	});
	</script>
	
  </body>
  
  <% if(request.getAttribute("dele")!=null){
	  %>
	  <script type="text/javascript">
	  $(document).ready(function(){
		  alert("删除成功");
	  })</script>
 <% 
  }%>
</html>
